package com.cf.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cf.entity.ErpQtnProductCostEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

@Mapper
public interface ErpQtnProductCostEntityMapper extends BaseMapper<ErpQtnProductCostEntity> {

    @Select("select  ROW_NUMBER() over(order by T1.ConfirmName) seqNo,"
            + "T1.confirmName,T1.specification,T1.unit,T1.quantity,"
            + "sum(T0.CostPrice) costPrice ,sum(T0.CostAmount) costAmount " + "from CharlieQtnProductCost T0 "
            + "inner join CharlieQtnProduct T1 on T0.ProductId=T1.ID " + "where T0.QuotationID=#{quotationID} "
            + "GROUP BY  T1.ConfirmName,T1.Specification,T1.Unit,T1.quantity  ")
    List<Map<String, Object>> subTotal(int quotationID);

    @Select("select isnull(sum(CostAmount),0) total  from CharlieQtnProductCost   where quotationID=#{quotationID}")
    Map<String, Object> total(int quotationID);

}
